<template>
  <view class="container">
    <!-- Banner Section -->
    <view class="banner" v-if="user.share_status == 1 && user.grade_id>1">
	  <button open-type="share" class="share-button">分享给好友</button>
    </view>
	<view class="banner" v-else >
	  <button class="share-button" @click="showTip()">分享给好友</button>
	</view>

    <!-- Navigation List -->
    <view class="nav-list">
      <view class="nav-item" @click="navigate('/pages/agent/bonus/bonus')">
        <text class="nav-text">我的奖金</text>
        <image src="/static/arrow-right.png" class="arrow-icon"></image>
      </view>
	  <view class="nav-item" @click="navigate('/pages/agent/peas/peas')">
	    <text class="nav-text">我的蜜豆</text>
	    <image src="/static/arrow-right.png" class="arrow-icon"></image>
	  </view>
	  <view class="nav-item" @click="navigate('/pages/agent/my_recommend/my_recommend')" v-if="is_store_user == 0">
	    <text class="nav-text">我的推荐</text>
	    <image src="/static/arrow-right.png" class="arrow-icon"></image>
	  </view>
	  <view class="nav-item" @click="navigate('/pages/agent/resettle/resettle')" v-if="is_store_user == 0">
	    <text class="nav-text">我的安置</text>
	    <image src="/static/arrow-right.png" class="arrow-icon"></image>
	  </view>
	  <view class="nav-item" @click="navigate('/pages/agent/points/points')" v-if="is_store_user == 0">
	    <text class="nav-text">我的{{setting.points_name}}</text>
	    <image src="/static/arrow-right.png" class="arrow-icon"></image>
	  </view>
	  <view class="nav-item" @click="navigate('/pages/agent/qrcode/qrcode')" v-if="is_store_user == 0 && user.share_status && user.grade_id>1">
	    <text class="nav-text">我的二维码</text>
	    <image src="/static/arrow-right.png" class="arrow-icon"></image>
	  </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
		is_store_user:0,
		setting:{},
		share_title:'三开创美',
		user:{},
		navItems: [
			{ text: "我的奖金", link: "/pages/agent/bonus/bonus" },
			{ text: "我的蜜豆", link: "/pages/agent/peas/peas" },
			{ text: "我的推荐", link: "/pages/agent/my_recommend/my_recommend" },
			{ text: "我的安置", link: "/pages/agent/resettle/resettle" },
			
			/*
			{ text: "我的安置", link: "/pages/agent/resettle/resettle" },
			{ text: "待安置会员", link: "/pages/agent/noresettle/noresettle" },
			{ text: "原来商业中心", link: "/pages/agent/index/index" },
			{ text: "提现银行卡", link: "/pages/withdraw-card/index" },
			{ text: "支付银行卡", link: "/pages/payment-card/index" },
			{ text: "消费明细", link: "/pages/expense-details/index" },
			*/
		],
    };
  },
	onLoad(){
		this.getData();
	},
	onShow() {
		
	},
    onShareAppMessage() {
		let self = this;
		return {
			title: self.share_title,
			path: '/pages/login/bhregister?' + self.getShareUrlParams(),
			imageUrl: '/static/background_top.png', // 分享的图片
		};
    },
    onShareTimeline() {
		let self = this;
		return {
			title: self.share_title, // 分享标题
			query: self.getShareUrlParams(), // 分享携带的参数
			imageUrl: '/static/background_top.png', // 分享的图片
		};
    },
  methods: {
	  showTip(){
		  this.showError('禁止分享！！！')
	  },
	  /*获取数据*/
	  getData() {
	  	let self = this;
	  	self.isloadding = true;
	  	self._get('user.index/detail', {
	  		url: self.url
	  	}, function(res) {
	  		self.setting = res.data.setting;
			self.user = res.data.userInfo;
			self.is_store_user = res.data.is_store_user;
			let points_name = '我的'+self.setting.points_name
			let pointsNav = { text: points_name, link: "/pages/agent/points/points" }
			self.navItems.splice(2, 0,pointsNav)
			if(self.user.share_status && self.user.grade_id>1){
				self.navItems.push({ text: "我的二维码", link: "/pages/agent/qrcode/qrcode" });
			}
	  		self.isloadding = false;
	  	});
	  },
    navigate(link) {
      uni.navigateTo({ url: link });
    },
  },
};
</script>

<style>
.container {
  background-color: #f5f5f5;
  height: 100%;
}

/* Header Section */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background-color: #ffffff;
  border-bottom: 1px solid #eaeaea;
}
.header-title {
  font-size: 18px;
  font-weight: bold;
}
.header-icons {
  display: flex;
  gap: 10px;
}
.icon {
  width: 24px;
  height: 24px;
}

/* Banner Section */
.banner {
  position: relative; /* 关键：设定相对定位 */
  width: 100%; /* 设置宽度 */
  display: flex;
  justify-content: center;
  align-items: center;
}

.banner-img {
  width: 100%; /* 图片宽度占满父容器 */
  height: 148px; /* 图片高度占满父容器 */
  object-fit: cover; /* 图片自适应，保证不拉伸 */
  border-radius: 10px; /* 可选：设置圆角 */
}

.share-button {
  width: 100%;
  height: 250rpx;
  background-image: url('/static/share_btn.jpg'); /* 设置背景图片路径 */
  background-size: cover; /* 背景图等比例拉伸，铺满整个按钮 */
  background-repeat: no-repeat; /* 背景图片不重复 */
  background-position: center; /* 图片居中显示 */
  border: none; /* 去除按钮默认边框 */
  color: #fff; /* 设置文字颜色 */
  font-size: 28rpx; /* 设置字体大小 */
  text-align: center; /* 文字居中 */
  line-height: 100rpx; /* 与按钮高度一致，实现垂直居中 */
  border-radius: 10rpx; /* 按钮圆角 */
  padding: 0;
}


/* Navigation List */
.nav-list {
  background-color: #ffffff;
  margin-top: 10px;
}
.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #eaeaea;
}
.nav-item:last-child {
  border-bottom: none;
}
.nav-text {
  font-size: 16px;
  color: #333333;
}
.arrow-icon {
  width: 20px;
  height: 20px;
}
</style>
